package create.singleton;

/**
 * @author dali
 * @date 2021-07-06 11:42
 * @Description 懒汉3 同步代码块
 */

public class LanHan3 {
    //防外部new
    private LanHan3() {}
    //静态定义
    private static LanHan3 instance;
    //返回对象时获取
    public static LanHan3 getInstance() {
        //如果为空则创建
        if (instance == null) {
            synchronized (LanHan3.class) {
                instance = new LanHan3();
            }
        }
        return instance;
    }
}
